// 清除浮动
@mixin clearfix {
  &::after {
    content: '';
    display: table;
    clear: both;
  }
}

// 文本省略
@mixin text-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

// 多行文本省略
@mixin multi-line-ellipsis($lines: 2) {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: $lines;
  overflow: hidden;
}

// flex 布局
@mixin flex($direction: row, $justify: center, $align: center) {
  display: flex;
  flex-direction: $direction;
  justify-content: $justify;
  align-items: $align;
}

// 绝对定位居中
@mixin absolute-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

// 响应式断点 - 简化版
@mixin respond-to($breakpoint) {
  @if $breakpoint == xs {
    @media (max-width: $breakpoint-xs) {
      @content;
    }
  } @else if $breakpoint == sm {
    @media (max-width: $breakpoint-sm) {
      @content;
    }
  } @else if $breakpoint == md {
    @media (max-width: $breakpoint-md) {
      @content;
    }
  } @else if $breakpoint == lg {
    @media (max-width: $breakpoint-lg) {
      @content;
    }
  } @else if $breakpoint == xl {
    @media (min-width: $breakpoint-lg) {
      @content;
    }
  }
}

// 滚动条样式
@mixin scrollbar($width: 6px, $thumb-color: rgba(0, 0, 0, 0.3), $track-color: transparent) {
  &::-webkit-scrollbar {
    width: $width;
    height: $width;
  }

  &::-webkit-scrollbar-thumb {
    background-color: $thumb-color;
    border-radius: $width / 2;
  }

  &::-webkit-scrollbar-track {
    background-color: $track-color;
  }
}

// 渐变背景
@mixin gradient-bg($start-color, $end-color, $direction: to right) {
  background: linear-gradient($direction, $start-color, $end-color);
}

// 阴影效果
@mixin box-shadow($level: 'base') {
  @if $level == 'light' {
    box-shadow: $box-shadow-light;
  } @else if $level == 'dark' {
    box-shadow: $box-shadow-dark;
  } @else {
    box-shadow: $box-shadow-base;
  }
}

// 按钮基础样式
@mixin button-base {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: none;
  border-radius: $border-radius-base;
  font-size: $font-size-base;
  cursor: pointer;
  transition: all 0.3s;

  &:disabled {
    cursor: not-allowed;
    opacity: 0.6;
  }
}

// 卡片基础样式
@mixin card-base {
  background-color: var(--background-color-extra-light);
  border-radius: $border-radius-base;
  padding: $spacing-base;
  @include box-shadow('light');
}

// 移动端1px边框
@mixin border-1px($color: var(--border-color-base), $direction: all) {
  position: relative;
  
  &::after {
    content: '';
    position: absolute;
    background-color: $color;
    
    @if $direction == all {
      left: 0;
      top: 0;
      width: 200%;
      height: 200%;
      transform: scale(0.5);
      transform-origin: left top;
    } @else if $direction == bottom {
      left: 0;
      bottom: 0;
      width: 100%;
      height: 1px;
      transform: scaleY(0.5);
    } @else if $direction == top {
      left: 0;
      top: 0;
      width: 100%;
      height: 1px;
      transform: scaleY(0.5);
    } @else if $direction == left {
      left: 0;
      top: 0;
      width: 1px;
      height: 100%;
      transform: scaleX(0.5);
    } @else if $direction == right {
      right: 0;
      top: 0;
      width: 1px;
      height: 100%;
      transform: scaleX(0.5);
    }
  }
}